<template>
	<view>
		<view class="header status_bar" :class="scrrol == true ? 'scrrolHeader' : ''">
			<view class="back iconfont icon-xiangzuo1" @tap="backPage"></view>
			<view class="text" :class="scrrol == true ? 'scrrolHeader' : ''">分销团队</view>
		</view>	
		<view class="bg_box">
			<image class="bg01" :src="getImgSrc('/static/bg02.png')" mode="widthFix"></image>
			<view class="bg_content">
				
				<view class="rank_box">
					<view class="name_box">
						<view class="avatar">
							<image :src="avatar" mode="scaleToFill"></image>
						</view>
						<view class="text_box">
							<view class="name">{{phone}}</view>
							<view class="text">团队人数: {{team_num}}人</view>
						</view>
						<view class="menu" v-if="is_agent == 0">普通</view>
						<view class="menu" v-if="is_agent == 1">代理商</view>
					</view>
					<view class="rank_list">
						<view class="list">
							<view class="other">账号</view>
							<view class="other">级别</view>
							<!-- <view class="other">团队人数</view> -->
							<view class="other">加入时间</view>
						</view>
						<block v-for="(item, index) in info" :key="index">
							<view class="list">
								<view class="other">{{item.nickname}}</view>
								<view class="other">{{item.lelvel}}</view>
								<!-- <view class="other">0</view> -->
								<view class="other">{{item.time}}</view>
							</view>
						</block>
					</view>
				</view>

				<view class="clear_box"></view>
			</view>
		</view>
		
	</view>
</template>

<script>
	export default {
		data() {
			return {
				page:1,
				scrrol:false,
				info:'',
				team_num:0,
				avatar:'',
				phone:'',
				is_agent:0,
			}
		},
		onLoad(e) {
			let that = this;
			that.avatar = e.avatar;
			that.phone = e.phone;
			that.is_agent = e.is_agent;
			that.loadData();
		},
		methods: {
			loadData() {
				let that = this;
				that.Net._get('auth/team', {per_page:'10',page:that.page}, res => {
					if (res.code == 200) {
						that.info = res.data.list.data;
						that.team_num = res.data.num;
					}
				});
			},
			backPage() {
				uni.navigateBack({});
			},
			gotopage(e) {
				let url = e.currentTarget.dataset.url;
				uni.navigateTo({
					url: url
				});
			},

		},
		onPageScroll: function(Object) {
			//console.log(Object.scrollTop); //实时获取到滚动的值
			if (Object.scrollTop > 28) {
				this.scrrol = true;
				/* #ifdef APP-PLUS */
				/* #endif */
			} else if (Object.scrollTop < 28) {
				this.scrrol = false;
				/* #ifdef APP-PLUS */
				/* #endif */
			}
		},
		onReachBottom() {
			var that = this;
			that.page++;
			that.Net._get('auth/team', {per_page:'10',page:that.page,}, res => {
				if (res.code == 200) {
				//console.log(res)
					if (res.data.list.data == '') {
						uni.showToast({
							title: '已经是最后一页了',
							duration: 2000,
							icon: 'none'
						});
					} else {
						that.info = that.info.concat(res.data.list.data); //将数据拼接在一起
					}
				} else if (res.code == 0) {
					that.Msg.Success(res.msg, res => {});
				}
			});
		},
	}
</script>

<style>
	
	.header{
		background-color: transparent !important;
	}
	
	.header .text{
		background-color: transparent !important;
		color: #333 !important;
	}
	
	.header .back{
		color: #333 !important;
	}
	
	.scrrolHeader{
		background-color: #FFF2E2 !important;
	}
	
	.bg_box{
		width: 100%;
		position: relative;
	}
	
	.bg_box .bg01{
		width: 100%;
	}
	
	.bg_box .bg_content{
		width: 92%;
		position: absolute;
		left: calc(50% - 46%);
		top: calc(13.5vw + var(--status-bar-height));
		z-index: 98;
	}
	
	.rank_box {
		width: 100%;
		margin: 4% auto 0;
		background-color: #fff;
		border-radius: 4vw;
		box-sizing: border-box;
	}
	
	.rank_box .name_box {
		width: 100%;
		padding: 4% 4% 0 4%;
		box-sizing: border-box;
		display: flex;
		align-items: center;
	}
	
	.rank_box .name_box .avatar {
		width: 16vw;
		height: 16vw;
		border-radius: 50%;
		margin-right: 2vw;
	}
	
	.rank_box .name_box .avatar image {
		width: 100%;
		height: 100%;
		border-radius: 50%;
	}
	
	.rank_box .name_box .text_box {
		flex: 1;
	}
	
	.rank_box .name_box .text_box .name {
		font-size: 3.8vw;
		color: #333;
	}
	
	.rank_box .name_box .text_box .text {
		font-size: 3.5vw;
		color: #666666;
		margin-top: 2vw;
	}
	
	.rank_box .name_box .menu {
		width: 18vw;
		height: 9vw;
		border-radius: 9vw;
		background-color: #F7DEB5;
		font-size: 4vw;
		color: #333;
		display: flex;
		align-items: center;
		justify-content: center;
	}

	.rank_list {
		width: 100%;
		margin-top: 4%;
	}
	
	.rank_list .list {
		width: 100%;
		height: 12vw;
		display: flex;
		align-items: center;
	}
	
	
	.rank_list .list .other {
		flex: 1;
		font-size: 3vw;
		color: #555555;
		display: flex;
		align-items: center;
		justify-content: center;
	}
	
	.rank_list .list:nth-child(1) {
		background-color: #F7DEB5;
	}
	
	.rank_list .list:nth-child(1) .other {
		color: #333;
		font-size: 3.5vw;
	}
	
	
	
	
</style>
